package com.speaktoitcookbook.service;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;

import com.speaktoitcookbook.bean.Material;
import com.speaktoitcookbook.dao.IMaterialDao;
import com.speaktoitcookbook.dao.factory.DaoFactory;

@WebServlet("/ShareCookbookService")
public class ShareCookbookService extends HttpServlet{
	private static final long serialVersionUID = 1L;
	long cbID = 0;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
       doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("application/json");
		
		cbID = -1;
		try {
			cbID = Long.parseLong(request.getParameter("cbID"));
			DaoFactory.getCookbookDao().doShare(cbID);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	

}